import numpy as np


def Sigmoid(x):
    if x >= 0:
        return 1
    if x < 0:
        return 0


class Neuron:
    def __init__(self, weights, bias):
        self.weights = weights
        self.bias = bias

    def feedforward(self, inputs):
        total = np.dot(self.weights, inputs) - self.bias
        return Sigmoid(total)


class NeuralNetwork:
    def __init__(self):
        weights = np.array([5, 3, 2])
        bias = 0

        self.h1 = Neuron(weights, bias)
        self.h2 = Neuron(weights, bias)
        self.h3 = Neuron(weights, bias)
        self.o1 = Neuron(weights, bias)

    def feedforward(self, x):
        out_h1 = self.h1.feedforward(x)
        out_h2 = self.h2.feedforward(x)
        out_h3 = self.h3.feedforward(x)

        # o1 的输入是 h1 和 h2 的输出
        out_o1 = self.o1.feedforward(np.array([out_h1, out_h2, out_h3]))

        return out_o1


network = NeuralNetwork()
x = np.array([1, 0, 1])  # x1=1, x2=0, x3=1
print(network.feedforward(x))
